import axios from 'axios'
import store from '@/store'
import { getToken } from '@/utils/auth'
const service = axios.create({
  baseURL: '',
  timeout: 50000
})

service.interceptors.request.use(config => {
  if (store.getters.token) {
    config.headers.token = getToken()
  }
  return config
}, error => {
//   console.log(error)
  return Promise.reject(error)
})

service.interceptors.response.use(response => {
  return response
}, error => {
//   console.log(error)
  //   this.$message({
  //     showClose: true,
  //     message: error.message || 'Error',
  //     type: 'success'
  //   })
  return Promise.reject(error)
})
export default service
